/**
 * 
 */
package com.dava.helpmywife.data;

import android.app.Activity;
import android.app.Application;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.util.Log;

/**
 * @author Dava
 * 
 */
public class initDataApp extends Application {
	private final String PREFERENCES_NAME = "userInfo";
	private final String tag = "SoftLog";
	private boolean isSendMsg;
	private boolean isCall;
	private boolean isAlert;
	private boolean isShorIco;
	/**
	 * @return the isShorIco
	 */
	public boolean isShorIco() {
		return isShorIco;
	}

	/**
	 * @param isShorIco the isShorIco to set
	 */
	public void setShorIco(boolean isShorIco) {
		this.isShorIco = isShorIco;
	}

	/**
	 * @return the isSendMsg
	 */
	public boolean isSendMsg() {
		return isSendMsg;
	}

	/**
	 * @param isSendMsg
	 *            the isSendMsg to set
	 */
	public void setSendMsg(boolean isSendMsg) {
		this.isSendMsg = isSendMsg;
	}

	/**
	 * @return the isCall
	 */
	public boolean isCall() {
		return isCall;
	}

	/**
	 * @param isCall
	 *            the isCall to set
	 */
	public void setCall(boolean isCall) {
		this.isCall = isCall;
	}

	/**
	 * @return the isAlert
	 */
	public boolean isAlert() {
		return isAlert;
	}

	/**
	 * @param isAlert
	 *            the isAlert to set
	 */
	public void setAlert(boolean isAlert) {
		this.isAlert = isAlert;
	}
	/**
	 * 初始化数据
	 */
	@Override
	public void onCreate() {
		SharedPreferences preferences = getSharedPreferences(PREFERENCES_NAME,Activity.MODE_PRIVATE);
		setSendMsg(preferences.getBoolean("isSendMsg", false));
		setCall(preferences.getBoolean("isCall", false));
		setAlert(preferences.getBoolean("isAlert", true));
		setShorIco(preferences.getBoolean("isShorIco", false));
		Log.i(tag, "start init app data!"+"isSendMsg:"+isSendMsg()+" isCall:"+isCall()+" isAlert:"+isAlert()+" isShorIco:"+isShorIco());
		super.onCreate();
	}
	/**
	 * 更新application信息
	 */
	public void update() {
		SharedPreferences preferences = getSharedPreferences(PREFERENCES_NAME,Activity.MODE_PRIVATE);
		setSendMsg(preferences.getBoolean("isSendMsg", false));
		setCall(preferences.getBoolean("isCall", false));
		setAlert(preferences.getBoolean("isAlert", true));
		setShorIco(preferences.getBoolean("isShorIco", false));
	}
}
